/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vista;

import modelo.Clave;

/**
 *
 * @authors Matías Barrera G. Luis Castillo S.
 */
public class JIFNuevaClave extends javax.swing.JInternalFrame {

    // crear un objeto de tipo clave para guardar los datos de la clave
    private Clave clv = new Clave();

    public Clave getPacTmp() {
        return this.clv;
    }

    /**
     * Creates new form JIFnuevaClave
     */
    public JIFNuevaClave() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        PanelClave = new javax.swing.JPanel();
        NombreLabel = new javax.swing.JLabel();
        UrlLabel = new javax.swing.JLabel();
        NombreTF = new javax.swing.JTextField();
        UrlTF = new javax.swing.JTextField();
        ClaveLabel = new javax.swing.JLabel();
        ComentarioLabel = new javax.swing.JLabel();
        ComentarioTF = new javax.swing.JTextField();
        EncriptarButton = new javax.swing.JButton();
        SugerirButton = new javax.swing.JButton();
        ClavePF = new javax.swing.JPasswordField();
        GrupoLabel = new javax.swing.JLabel();
        GrupoComboBox = new javax.swing.JComboBox();
        NuevoGrupoButton = new javax.swing.JButton();
        IdentificadorLabel = new javax.swing.JLabel();
        IdentificadorTF = new javax.swing.JTextField();
        CancelarButton = new javax.swing.JButton();
        GuardarButton = new javax.swing.JButton();

        setClosable(true);

        PanelClave.setBorder(javax.swing.BorderFactory.createTitledBorder("Clave"));

        NombreLabel.setText("Nombre");

        UrlLabel.setText("URL");

        ClaveLabel.setText("Clave");

        ComentarioLabel.setText("Comentario");

        EncriptarButton.setText("Encriptar");
        EncriptarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EncriptarButtonActionPerformed(evt);
            }
        });

        SugerirButton.setText("Sugerir");

        GrupoLabel.setText("Grupo");

        GrupoComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        NuevoGrupoButton.setText("Nuevo Grupo");

        IdentificadorLabel.setText("Identificador");

        IdentificadorTF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                IdentificadorTFActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout PanelClaveLayout = new javax.swing.GroupLayout(PanelClave);
        PanelClave.setLayout(PanelClaveLayout);
        PanelClaveLayout.setHorizontalGroup(
            PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelClaveLayout.createSequentialGroup()
                .addGap(56, 56, 56)
                .addGroup(PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, PanelClaveLayout.createSequentialGroup()
                        .addGroup(PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(UrlLabel)
                            .addComponent(NombreLabel)
                            .addComponent(GrupoLabel))
                        .addGap(30, 30, 30)
                        .addGroup(PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(UrlTF)
                            .addComponent(NombreTF, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(PanelClaveLayout.createSequentialGroup()
                                .addComponent(GrupoComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(NuevoGrupoButton)
                                .addGap(35, 35, 35))))
                    .addComponent(ComentarioLabel, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ComentarioTF, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, PanelClaveLayout.createSequentialGroup()
                        .addGroup(PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(IdentificadorLabel)
                            .addComponent(ClaveLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(IdentificadorTF)
                            .addComponent(ClavePF))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(SugerirButton)
                    .addComponent(EncriptarButton))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        PanelClaveLayout.setVerticalGroup(
            PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelClaveLayout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(NombreLabel)
                    .addComponent(NombreTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(UrlLabel)
                    .addComponent(UrlTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(GrupoLabel)
                    .addComponent(GrupoComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(NuevoGrupoButton))
                .addGap(18, 18, 18)
                .addGroup(PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(IdentificadorLabel)
                    .addComponent(IdentificadorTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PanelClaveLayout.createSequentialGroup()
                        .addGap(0, 32, Short.MAX_VALUE)
                        .addComponent(SugerirButton)
                        .addGroup(PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(PanelClaveLayout.createSequentialGroup()
                                .addGap(20, 20, 20)
                                .addComponent(ComentarioLabel))
                            .addGroup(PanelClaveLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(EncriptarButton))))
                    .addGroup(PanelClaveLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(PanelClaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(ClavePF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ClaveLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addComponent(ComentarioTF, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(45, 45, 45))
        );

        CancelarButton.setText("Cancelar");

        GuardarButton.setText("Guardar");
        GuardarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GuardarButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(GuardarButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(CancelarButton))
                    .addComponent(PanelClave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(68, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(PanelClave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CancelarButton)
                    .addComponent(GuardarButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(13, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void EncriptarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EncriptarButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_EncriptarButtonActionPerformed

    private void GuardarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GuardarButtonActionPerformed
        //guardar los datos de la clave
        this.clv.setNombre(NombreTF.getText());
        this.clv.setUrl(UrlTF.getText());
        this.clv.setIdentificador(Integer.parseInt(IdentificadorTF.getText()));
        this.clv.setClave(ClavePF.getText());
        this.clv.setComentario(ComentarioTF.getText());

        this.dispose();

    }//GEN-LAST:event_GuardarButtonActionPerformed

    private void IdentificadorTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IdentificadorTFActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_IdentificadorTFActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CancelarButton;
    private javax.swing.JLabel ClaveLabel;
    private javax.swing.JPasswordField ClavePF;
    private javax.swing.JLabel ComentarioLabel;
    private javax.swing.JTextField ComentarioTF;
    private javax.swing.JButton EncriptarButton;
    private javax.swing.JComboBox GrupoComboBox;
    private javax.swing.JLabel GrupoLabel;
    private javax.swing.JButton GuardarButton;
    private javax.swing.JLabel IdentificadorLabel;
    private javax.swing.JTextField IdentificadorTF;
    private javax.swing.JLabel NombreLabel;
    private javax.swing.JTextField NombreTF;
    private javax.swing.JButton NuevoGrupoButton;
    private javax.swing.JPanel PanelClave;
    private javax.swing.JButton SugerirButton;
    private javax.swing.JLabel UrlLabel;
    private javax.swing.JTextField UrlTF;
    // End of variables declaration//GEN-END:variables
}